$(function () {
    // ********************************添加用户
    let form;
    let layer;
    layui.use('form', function () {
        form = layui.form;
        layer = layui.layer;

        form.verify({
            password: [
                /^[\S]{6,12}$/, '密码必须6到12位，且不能出现空格'
            ],
            same: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (value != $('.pass').val()) {
                    return '确认密码与原密码不一致';
                }
            }
        });



        $('form').on('submit', function (e) {

            e.preventDefault()

            let data = $(this).serialize()


            $.ajax({
                url: '/admin/users',
                type: 'post',
                data: data,
                success: function (res) {
                    layer.msg(res.message);
                }

            })

        })
    });















})